package com.qf.java2201.web.bk;

import com.alibaba.fastjson.JSON;
import com.qf.java2201.common.R;
import com.qf.java2201.pojo.HType;
import com.qf.java2201.service.TypeService;
import com.qf.java2201.service.impl.TypeServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

/**
 * @date 2022/4/9
 * @desc   数据字典表 相关操作
 */
@WebServlet("/htype")
public class HtypeServlet extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doPost(req,resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

        TypeService typeService = new TypeServiceImpl();

        PrintWriter writer = resp.getWriter();

        String method = req.getParameter("method");


        if(method.equals("doctorTypeList")){
            //查询科室列表
            //List<HType> list =  typeService.findListByTgroup(2);
            List<HType> list =  typeService.findAllTypes();

            R ok = R.ok();
            ok.setData(list);

            String s = JSON.toJSONString(ok);

            writer.println(s);
        }


    }
}
